<template>
    <div>
        <h3>{{content.title}}</h3>
        <div class="subtitle">
            <span>发表时间：{{content.add_time | dateFormat}}</span>
            <span>点击次数：{{content.click}}次</span>
        </div>
        <!-- 图片缩略图 -->
        <vue-preview :slides="slide1" @close="handleClose" class="preview"></vue-preview>
        <!-- 图片内容 -->
        <div class="content" v-html="content.content">
        </div>
        <!-- 导入公用的 评论组件 -->
        <comment :id="id"></comment>
    </div>
</template>
<script>
import comment from '../subcomponent/Comment.vue'

export default {
    data(){
        return{
            id: this.$route.params.id,
            content:{},//图片内容
            slide1:[]//缩略图图片数组
        }
    },
    created(){
        this.getImgInfo()
        this.getThumimages()
    },
    methods:{
        getImgInfo(){
            this.$http.get('getimageInfo/'+this.id).then(res => {
                if(res.body.status === 0){
                    this.content = res.body.message[0]
                }
            })
        },
        getThumimages(){
            this.$http.get('getthumimages/'+this.id).then( res => {
                if(res.body.status === 0){
                    res.body.message.forEach( item => {
                        item.w = 600
                        item.h = 400
                        item.msrc = item.src
                    })
                    this.slide1 = res.body.message
                }
            })
        },
        handleClose () {
        console.log('close event')
      }
    },
    components:{
        comment
    }
}
</script>
<style  scoped>

</style>